package com.qls.web.modules.op.controller;

import com.qls.core.entity.OpOurRateplanPrice;
import com.qls.core.utils.R;
import com.qls.web.common.utils.PageUtils;
import com.qls.web.modules.op.service.OpOurRateplanPriceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 自定义价格计划加价配置
 *
 * @author yj
 * @email yj@gmail.com
 * @date 2021-09-10 16:21:41
 */
@RestController
@RequestMapping("op/ourrateplanprice")
public class OpOurRateplanPriceController {
    @Autowired
    private OpOurRateplanPriceService ourRateplanPriceService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("op:ourrateplanprice:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = ourRateplanPriceService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("op:ourrateplanprice:info")
    public R info(@PathVariable("id") Integer id) {
        OpOurRateplanPrice ourRateplanPrice = ourRateplanPriceService.getById(id);

        return R.ok().put("ourRateplanPrice", ourRateplanPrice);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("op:ourrateplanprice:save")
    public R save(@RequestBody OpOurRateplanPrice ourRateplanPrice) {
        ourRateplanPriceService.save(ourRateplanPrice);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("op:ourrateplanprice:update")
    public R update(@RequestBody OpOurRateplanPrice ourRateplanPrice) {
        ourRateplanPriceService.updateById(ourRateplanPrice);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("op:ourrateplanprice:delete")
    public R delete(@RequestBody Integer[] ids) {
        ourRateplanPriceService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
